//
//  todayListTopicTableViewCell.m
//  Cup
//
//  Created by dllo on 15/4/23.
//  Copyright (c) 2015年 doll. All rights reserved.
//

#import "todayListTopicTableViewCell.h"
#define WIDTH self.contentView.frame.size.width
@implementation todayListTopicTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.headLabel = [[UILabel alloc] init];
        self.headLabel.font = [UIFont systemFontOfSize:12];
        [self.contentView addSubview:self.headLabel];
        [self.headLabel release];
        
        self.articleImageView = [[UIImageView alloc] init];
        [self.contentView addSubview:self.articleImageView];
        [self.articleImageView release];
        
        self.titleLabel = [[UILabel alloc] init];
        self.titleLabel.numberOfLines = 0;
        [self.titleLabel sizeToFit];
        self.titleLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:18];
        [self.contentView addSubview:self.titleLabel];
        [self.titleLabel release];
                
        self.introduceLabel = [[UILabel alloc] init];
        self.introduceLabel.numberOfLines = 3;
        self.introduceLabel.font = [UIFont systemFontOfSize:15];
        [self.contentView addSubview:self.introduceLabel];
        [self.introduceLabel release];
        
        self.likeImageView = [[UIImageView alloc] init];
        [self.contentView addSubview:self.likeImageView];
        [self.likeImageView release];
        
        self.likeLabel = [[UILabel alloc] init];
        self.likeLabel.font = [UIFont systemFontOfSize:13];
        [self.contentView addSubview:self.likeLabel];
        [self.likeLabel release];
    }
    return self;
}

// 自定义cell内部控件的的布局
- (void)layoutSubviews
{
    [super layoutSubviews];
    self.headLabel.frame = CGRectMake(30, 10, WIDTH, 20);
    
    NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:[UIFont fontWithName:@"Helvetica-Bold" size:18],NSFontAttributeName, nil];
    CGRect rect = [self.titleLabel.text boundingRectWithSize:CGSizeMake(WIDTH - 60, 400) options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil];
    self.titleLabel.frame = CGRectMake(30, 37, WIDTH - 60, rect.size.height);
    
    self.articleImageView.frame = CGRectMake(30, 45 + rect.size.height, WIDTH - 60, 160);
    
    self.introduceLabel.frame = CGRectMake(30, 207 + rect.size.height, WIDTH - 60, 70);
    
    UIImage *likeImage = [UIImage imageNamed:@"like"];
    self.likeImageView.image = likeImage;
    self.likeImageView.frame = CGRectMake(0.693 * WIDTH, 295 + rect.size.height, 18, 18);
    
    self.likeLabel.frame = CGRectMake(0.7653 * WIDTH, 295 + rect.size.height, 60, 18);
}

// 内存管理
- (void)dealloc
{
    [_headLabel release];
    [_articleImageView release];
    [_titleLabel release];
    [_introduceLabel release];
    [_likeImageView release];
    [_likeLabel release];
    [super dealloc];
}


- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
